<template>
  <div class="card-container" v-if="!$common.isEmpty(friendList)">
    <div v-for="(friend, index) in friendList"
         :key="index"
         class="card-item shadow-box wow"
         @click="clickFriendPath(friend)">
      <div class="card-image">
        <el-image class="my-el-image"
                  v-once
                  lazy
                  :src="friend.cover"
                  fit="cover">
          <div slot="error" class="image-slot myCenter" style="background-color: var(--lightGreen)">
            <div class="error-text">
              <div>遇事不决，可问春风</div>
            </div>
          </div>
        </el-image>
      </div>
      <div class="card-body">
        <div class="card-title">
          <span v-if="friend.status">🔥</span>
          {{ friend.name }}
        </div>
        <div class="card-desc">
          {{ friend.introduction }}
        </div>
        <div class="card-time">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-rili"/>
          </svg>
          发布于 {{ friend.createTime }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    friendList: {
      type: Array
    }
  },

  data() {
    return {}
  },

  computed: {},

  watch: {},

  created() {

  },

  mounted() {

  },

  methods: {
    clickFriendPath(friend) {
      this.$emit("clickFriendPath", friend.url);
    }
  }
}
</script>

<style scoped>

.card-container {
  display: flex;
  flex-wrap: wrap;
}

.card-item {
  position: relative;
  border-radius: 10px;
  background: rgba(255, 255, 255, .88);
  overflow: hidden;
  margin: 10px;
  height: 300px;
  flex-shrink: 0;
  width: calc(100% / 3 - 20px);
  cursor: pointer;
  animation: zoomIn 0.8s ease-in-out;
}

.card-image {
  width: 100%;
  height: 180px;
}

.card-image >>> .el-image__inner {
  transition: all 1s;
}

.card-image >>> .el-image__inner:hover {
  transform: scale(1.2);
}

.card-body {
  padding: 10px 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  transition: all .2s ease-in-out;
}

.card-title:hover {
  color: var(--lightGreen);
}

.card-desc {
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  letter-spacing: 1px;
}

.card-time {
  position: absolute;
  bottom: 10px;
  font-size: 12px;
  color: var(--greyFont);
}

@media screen and (max-width: 700px) {
  .card-item {
    width: calc(100% / 2 - 20px);
  }
}

@media screen and (max-width: 500px) {
  .card-item {
    width: calc(100% - 20px);
  }
}

</style>
